package com.etymgiko.spaceshipshop.service.impl;

import com.etymgiko.spaceshipshop.service.SpaceShipManager;
import com.etymgiko.spaceshipshop.model.SpaceShip;
import com.etymgiko.spaceshipshop.dao.SpaceShipDao;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

/**
 * Manages Spaceship.
 *
 * @author Ivan Holub
 */
public class SpaceShipManagerImpl implements SpaceShipManager {

    private SpaceShipDao spaceShipDao;

    public void setSpaceShipDao(SpaceShipDao spaceShipDao) {
        this.spaceShipDao = spaceShipDao;
    }

    /**
     * {@inheritDoc}
     */
    @Transactional(readOnly = true)
    public SpaceShip getSpaceShip(Long id) {
        return spaceShipDao.getSpaceShip(id);
    }

    /**
     * {@inheritDoc}
     */
    @Transactional(readOnly = false)
    public void saveSpaceShip(SpaceShip spaceShip) {
        spaceShipDao.saveSpaceShip(spaceShip);
    }

    /**
     * {@inheritDoc}
     */
    @Transactional(readOnly = true)
    public List<SpaceShip> findSpaceShips(Long userId, String filter, int pageNumber) {
        return spaceShipDao.findSpaceShips(userId, filter, pageNumber);
    }

    /**
     * {@inheritDoc}
     */
    @Transactional(readOnly = true)
    public long findSpaceShipsCount(Long userId, String filter) {
        return spaceShipDao.findSpaceShipsCount(userId, filter);
    }

}
